package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortPoint {
    public static void main(String[] args) {
        List<Point> list = new ArrayList();
        list.add(new Point(100,140));
        list.add(new Point(200,130));
        list.add(new Point(150,120));
        list.add(new Point(250,110));
        list.add(new Point(300,100));
        System.out.println(list);

//        Collections.sort(list);

        Collections.sort(list,new Comparator<Point>() {
            public int compare(Point a,Point b) {
                int c = a.getY()+a.getX();
                int d = b.getY()+b.getX();
                return d-c;
            }
        });

        list.sort(new Comparator<Point>() {
            public int compare(Point a,Point b) {
                return a.getY() - b.getY();
            }
        });
        System.out.println(list);
    }
}
